#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>

/**
 * @brief 阻塞式读取值
 * 
 * @param argc 
 * @param argv 
 * @return int 
 */

int main(int argc,char **argv)
{
    int fd = 0;
    char buf[8];
    int ret = 0;

    memset(buf, 0, sizeof(buf));

    fd = open("/dev/misc_usb_mouse", O_RDWR);
    if (fd < 0) {
        printf("open failed \n");
        return -1;
    }

    while (1) {
        ret = read(fd, buf, sizeof(buf));
        if (ret < 0) {
            printf("read failed \n");
            return -1;
        }
        
        printf("mouse data: ");
        for(int i = 0; i < sizeof(buf); i++) {
            printf("%02x ", buf[i]);
        }

        printf("\n");
    }

    close(fd);

    return 0;
}